package com.crm.service.impl.courseregist;

import com.crm.dao.mapper.courseregist.CourseConsumeRecordMapper;
import com.crm.dao.mapper.customMapper.courseregist.CourseConsumeRecordCustomMapper;
import com.crm.model.entity.courseregist.CourseConsumeRecord;
import com.crm.model.entity.courseregist.CourseConsumeRecordExample;
import com.crm.model.vo.courseregist.CourseConsumeRecordVO;
import com.crm.service.courseregist.CourseProductConsumeDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description: 消费产品记录
 * @author: lixq-f
 * @create: 2021/06/03
 */
@Service
public class CourseProductConsumeDbServiceImpl implements CourseProductConsumeDbService {

    @Autowired
    private CourseConsumeRecordMapper consumeRecordMapper;
    @Autowired
    private CourseConsumeRecordCustomMapper consumeRecordCustomMapper;

    @Override
    public Boolean insert(CourseConsumeRecord record) {
        return consumeRecordMapper.insert(record) > 0;
    }


    @Override
    public Boolean batchInsert(List<CourseConsumeRecord> records) {
        return consumeRecordCustomMapper.batchInsert(records);
    }



    /**
     * @Description: 根据课程ID和报名ID取消报名消费记录
     * @Param: [registId, courseId]
     * @Return: java.lang.Boolean
     * @Author: lixq-f
     * @Date: 2021/4/26
     **/
    @Override
    public Boolean deleteConsumeRecordByRegistId(String registId) {
        return consumeRecordCustomMapper.deleteConsumeRecordByRegistId(registId);
    }


    /**
     * @Description: 根据报名人ID列表获取消费记录
     * @Param: [registList]
     * @Return: java.util.List<com.crm.model.entity.courseregist.CourseConsumeRecord>
     * @Author: lixq-f
     * @Date: 2021/6/11
     **/
    @Override
    public List<CourseConsumeRecordVO> queryRecordsByRegistsId(List<String> registList) {
        return consumeRecordCustomMapper.queryRecordsByRegistsId(registList);
    }


    /**
     * @Description: 通过报名ID获取消费记录
     * @Param: [registId]
     * @Return: com.crm.model.entity.courseregist.CourseConsumeRecord
     * @Author: lixq-f
     * @Date: 2021/7/21
     **/
    @Override
    public  List<CourseConsumeRecord> getConsumeRecordByRegistId(String registId) {
        CourseConsumeRecordExample example = new CourseConsumeRecordExample();
        CourseConsumeRecordExample.Criteria criteria = example.createCriteria();
        criteria.andCourseRegistrationIdEqualTo(registId);
        return consumeRecordMapper.selectByExample(example);
    }


}
